package com.bsj.pay.task;

import com.bsj.pay.config.GlobalConfig;
import com.bsj.pay.service.PayGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ClearExpirePayPoolTask {
	@Autowired
	private PayGoodsService payGoodsService;
	
	private static boolean isReturn=true;

	@Scheduled(fixedRate = 30000)
	public void execute() {
		try {
			if (ClearExpirePayPoolTask.isReturn&&GlobalConfig.isInit)
			{
				ClearExpirePayPoolTask.isReturn = false;
				this.payGoodsService.removeExpirePayPoolTask();
				ClearExpirePayPoolTask.isReturn = true;
			}
		} catch (Exception e) {
			ClearExpirePayPoolTask.isReturn = true;
		}
	}
}